package pl.edu.agh;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import pl.edu.agh.strategies.SameAsLastWeek;

import static pl.edu.agh.Values.*;

public class MainLogic {

	public static int step(List<Agent> agents, boolean fakeVersion)
	{
		int wentCount = 0;
		Random rand = new Random();
		
		for(Agent bond : agents)
		{
			if(bond.decide())
			{
				wentCount++;
			}
		}
		
		for(Agent bond : agents)
		{
			if(fakeVersion)
			{
				int randomWents = rand.nextInt(101);
				bond.rateStrategiesAfterStep(randomWents);
				bond.addToHistory(randomWents);
			}
			else
			{
				bond.rateStrategiesAfterStep(wentCount);
				bond.addToHistory(wentCount);
			}
		}
		
		return wentCount;
	}
	
	public static void main2(String [] args)
	{
		ArrayList<Agent> agents = new ArrayList<Agent>();
		ArrayList<Integer> history = new ArrayList<Integer>();
		ArrayList<Class<? extends IStrategy>> strategies = new ArrayList<Class<? extends IStrategy>>();
		
		history.add(45);
		history.add(32);
		history.add(12);
		history.add(25);
		history.add(21);
		history.add(38);
		history.add(11);
		history.add(32);
		history.add(43);
		
		strategies.add(SameAsLastWeek.class);
		
		for(int i=0;i<maxPeople;i++)
		{
			Agent bond = new Agent(history, strategies, HowCountStrategies.ALL);
			agents.add(bond);
		}
		
		for(int i=0;i<5;i++)
		{
			System.out.println(step(agents, false));
			System.out.println(Arrays.toString(agents.get(0).getHistory().toArray()));
		}
	}
}
